package org.wlc.demov3.store.impl;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wlc.demov1.card.IQiYiCardService;
import org.wlc.demov3.store.ICommodity;

import java.util.Map;

/**
 * @author 王立朝
 * @date 2022/5/27
 * @description:  **第三方兑换卡**
 */
public class CardCommodityService implements ICommodity {

    private static final Logger logger = LoggerFactory.getLogger(CardCommodityService.class);

    private IQiYiCardService iQiYiCardService = new IQiYiCardService();
    /**
     * 统一的奖品发送接口
     *
     * @param uId         用户ID
     * @param commodityId 奖品ID
     * @param bizId       业务ID
     * @param extMap      扩展字段，用于处理发放实物商品时的收获地址
     * @throws Exception
     */
    @Override
    public void sendCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) throws Exception {
        String mobile = queryUserMobile(uId);
        iQiYiCardService.grantToken(mobile,bizId);
        logger.info("请求参数[爱奇艺兑换卡] => uId：{} commodityId：{} bizId：{} extMap：{}", uId, commodityId, bizId, JSON.toJSON(extMap));
        logger.info("测试结果[爱奇艺兑换卡]：success");
    }

    private String queryUserMobile(String uId) {
        return "15200101232";
    }
}
